package com.zc.demo.di;

import com.zc.demo.di.interfaces.Instrument;
import com.zc.demo.di.interfaces.Performer;

import java.util.Collection;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * 定义一个乐队
 * Created by zhangchi9 on 2016/11/2.
 */
public class OneManBand implements Performer{

    //定义乐器接口的集合
    private Collection<Instrument> instruments;
    public void setInstruments(Collection<Instrument> instruments){
        this.instruments = instruments;
    }

    private Set<Instrument> instrumentSet;
    public void setInstrumentSet(Set<Instrument> instrumentSet){
        this.instrumentSet = instrumentSet;
    }

    private Map<String,Instrument> instrumentMap;
    public void setInstrumentMap(Map<String,Instrument> instrumentMap){
        this.instrumentMap = instrumentMap;
    }

    private Properties properties;
    public void setProperties(Properties properties){
        this.properties = properties;
    }

    @Override
    public void perform() {
        for (Instrument instrument:instruments){
            instrument.play();
        }

        for (Instrument instrument:instrumentSet){
            instrument.play();
        }

        for (String key:instrumentMap.keySet()){
            System.out.println(key);
            Instrument instrument = instrumentMap.get(key);
            instrument.play();
        }

        for (Object key:properties.keySet()){
            System.out.println(key.toString());
            System.out.println(properties.get(key));
        }
    }
}
